import { Component, OnInit, ElementRef, Renderer2, ViewChild, AfterViewInit, Output, EventEmitter } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { fromEvent } from 'rxjs'; //引入
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-buss-right-info',
  templateUrl: './buss-right-info.component.html',
  styleUrls: ['./buss-right-info.component.scss']
})
export class BussRightInfoComponent implements OnInit {

  constructor(
    public http: HttpClient,
    public el: ElementRef,
    public renderer2: Renderer2,
    public route: ActivatedRoute,
  ) { }
  public rates: any = 5;

  public informList: any[] = []
  ngOnInit() {
    this.getLeftList();
  }
  // 获取通知列表并设置循环滚动
  // 获取通知公告的新闻列表
  leftList: any;
  initId: any;
  bulletinID: any;
  newsName: any;//新闻所属分类
  public rightInformList: any[] = [];

  getLeftList() {
    // let api="/assets/json/inform.json";
    let api = "/api/gsxmcp/pb/bl/v1.0/column";
    this.http.get(api).subscribe((response: any) => {
      if(response && response.length > 0){
        this.leftList = response;
        // console.log(response);
        this.newsName = response[0].name;
        this.initId = response[0].code;//设置信息列表中第几类信息response[0].code
        // console.log(this.initId);
        this.rightListFuc();
      }
    })
  }

  rightListFuc() {
    // this.bulletinID=this.initId;
    this.bulletinID = 'GSOUT_17';
    // 20210707 walle 调整了公告信息的查询参数
    let args = {
      pageNumber: 1,
      pageSize: 10,
      code: this.bulletinID,
      publishChannel: 'OBH'
    }
    let params = new HttpParams({ fromObject: args });
    let url = `/api/gsxmcp/pb/bl/v1.0/page`;
    this.http.get(url, { params }).subscribe((res: any) => {
      this.rightInformList = res['resultList'];
      this.informList = res['resultList'];
    })
  }

}
